<?php
/**
 * 管理用户
 * $Id: manage_user.php 238 2011-01-13 08:53:47Z bwanglei@gmail.com $
 */

require_once './globals.php';

if ($_SERVER['REQUEST_METHOD']=='POST' && $action=='edit-user') {
	require_once AW_ROOT.'/lib/class.phpass.php';	//包含密码类
	$aw_hash = new PasswordHash(8,true);
	//从表单获取数据
	$name = $_POST['username'];
	$password = $_POST['password'];
	if (trim($password) == $user_cache['password']) {
		$password = $user_cache['password'];
	} else {
		$password = $aw_hash->HashPassword($password);	//hash密码
	}
	$nickname = $_POST['nickname'];
	$email = $_POST['email'];
	//存入数据库
	$sql = 'UPDATE `'.DB_PREFIX.'users` SET `name`=\''.$name.'\', `password`=\''.$password.'\', `nickname`=\''.$nickname.'\', `email`=\''.$email.'\'';
	$DB->query($sql);
	//更新文件缓存
	$CACHE->updateCache('users');
	//冲读缓存数据
	$user_cache = $CACHE->readCache('users');
}
include_once TEMPLATE_PATH.'/header.php';
include_once TEMPLATE_PATH.'/manage_user.php';
include_once TEMPLATE_PATH.'/sidebar.php';
include_once TEMPLATE_PATH.'/footer.php';
